package com.xh.shuati.ai.tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class WebScrapingTool {

    @Tool(name = "webScrapingTool", value = "Scrape the content from a web page")
    public String scrapeWebPage(@P(value = "URL of the web page to scrape") String url){
        try {
            Document document = Jsoup.connect(url).get();
            return document.html();
        } catch (Exception e) {
            return "Error scraping web page: "+ e.getMessage();
        }
    }
}